package service;

import dao.DoctorDao;
import model.Doctor;

import java.util.List;

public class DoctorService {
    /**
     * 医生注册
     */
    public static boolean regist(Integer id,String name,String password,Integer sex,Integer deptId){
        List<Doctor> models = DoctorDao.select(id,null,null,null,null);
        boolean flag = false;
        if (models.size()>0){
            System.out.println("医生账号[" + id + "]已存在");
        }else {
            Doctor model = new Doctor(id,name,password,sex,deptId);
            DoctorDao.insert(model);
            System.out.println("医生注册成功。");
            flag = true;
        }
        return flag;
    }

    /**
     * 医生登陆
     */
    public static Doctor login(String id,String password){
        Doctor model = null;
        List<Doctor> models = DoctorDao.select(Integer.valueOf(id),null,password,null,null);
        if(models.size()>0){
            model = models.get(0);
            System.out.println("医生[" + model.getName() + "]登陆成功。");
        }else {
            System.out.println("医生账号或密码错误，登陆失败。");
        }
        return model;
    }
}
